public class Class1 {
    String name;//名字
    String dirTeacher;//指导老师
    String startDate;//开班日期
    String[] stus = new String[30];//不超过30人
    int count;

    public void add(String sname) {
        for (int i = 0; i < stus.length; i++) {
            if (stus[i] == null) {
                stus[i] = sname;
                count++;
            } else {
                System.out.println("人数已满，无法添加");
            }
        }
    }

    public void showInformation() {
        System.out.println("班级的名称为" + name);
        System.out.println("指导老师是" + dirTeacher);
        System.out.println("开班日期是" + startDate);
    }

    public String show(int index) {
        if (index >= 0 && index <= count) {
            return stus[index];
        }
        return "无该名同学信息";
    }
    public boolean update(String oldName,String newName){
        for (int i = 0; i < count; i++) {
            if (stus[i].equals(oldName)){
                stus[i]=newName;
                return true;
            }
        }return false;
    }
    public int getCount(){
        return count;
    }
}
